package com.wn.member.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import java.util.concurrent.TimeUnit;

/**
 * @author yellow Docter
 * @date 2022 -08-22
 * @desc
 */
@RestController
@RequestMapping("/member")
@Slf4j
public class MemberController {

    @GetMapping("{mid}")
    public String findMemberById(@PathVariable String mid){
        log.info("请求过来了...");
        return "hello 通过id查找 " + mid;
    }

    @GetMapping("/hello/{mid}")
    public String helloMemberById(@PathVariable String mid){

        log.info("请求过来了...");
        int i = 10/0;

        return "hello 通过id查找 " + mid;
    }


    @GetMapping("/time/{mid}")
    public String testMemberById(@PathVariable String mid){

        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("请求过来了...");

        return "hello 通过id查找 " + mid;
    }


    @DeleteMapping("{mid}")
    public String delMemberById(@PathVariable String mid){
        log.info("请求过来了...");
        return "hello 通过id删除 " + mid;
    }

    @GetMapping("/test/{mid}")
    public String findMemberTimeOut(@PathVariable Integer mid){

        // TimeUnit 时间单位类
        // 睡 2s
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        log.info("请求过来了...");
        return "TimeOut 通过id查找 " + mid;
    }

}
